<template>
  <div class="wraper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- <swiper-slide v-for="(item,index) of swiperList" :key="index"> -->
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" alt srcset />
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  name: "HomeSwiper",
  props: {
    list: Array
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination",
        loop: true
      }
      // swiperList: [
      //   {
      //     id: "0001",
      //     imgUrl:
      //       "//m.360buyimg.com/mobilecms/s700x280_jfs/t1/75948/38/8397/82820/5d65f62cE2c6e6cc5/2a102b700a294869.jpg!cr_1125x445_0_171!q70.jpg.dpg"
      //   },
      //   {
      //     id: "0002",
      //     imgUrl:
      //       "//m.360buyimg.com/mobilecms/s700x280_jfs/t1/62719/33/8204/141633/5d647d13E2cbe30c5/b7b5772a988d71be.jpg!cr_1125x445_0_171!q70.jpg.dpg"
      //   }
      // ]
    };
  },
  computed: {
    showSwiper() {
      return this.list.length;
    }
  }
};
</script>
<style lang="stylus" scoped>
.wraper>>>.swiper-pagination {
  bottom: 20px;

  .swiper-pagination-bullet-active {
    background: red !important;
  }
}

.wraper {
  width: 100%;
  height: 0;
  overflow: hidden;
  padding-bottom: 31.25%;
  background: #eee;

  .swiper-img {
    width: 100%;
  }
}
</style>